<template>
	<view>
		<uni-search-bar placeholder="搜索本市医院" @confirm="shou" @cancel="getyiyuan()" @clear="getyiyuan()"></uni-search-bar>
		<view class="u-demo">
			<image :src="base+yiyuan[0].imgUrl" mode="" style="width: 100%;"></image>
		</view>
		<uni-group title="医院列表">
			<uni-card v-for="(item,index) in yiyuan" :thumbnail="base+item.imgUrl" :title="item.hospitalName" @click="toindexx(item.id)">
				<uni-rate :value="item.level"></uni-rate>
			</uni-card>
		</uni-group>
		<view style="height: 20vh;"></view>
	</view>
</template>

<script>
	import api from '../../../../commer/apiURL.js'
	export default {
		data() {
			return {
				base:api.baseurl,
				yiyuan:[],
			}
		},
		onLoad() {
			this.getyiyuan()
		},
		onBackPress() {
			uni.switchTab({
				url:'../allserver'
			})
			return true
		},
		methods: {
			shou(e){
				this.yiyuan = this.yiyuan.filter((item)=>{
					return item.hospitalName.indexOf(e.value)>=0
				})
			},
			getyiyuan(){
				this.$get(this.base+'/prod-api/api/hospital/hospital/list').then((res)=>{
					this.yiyuan = res.rows
				})
			},
			toindexx(id){
				uni.navigateTo({
					url:'yiyuanxian?id='+id
				})
			}
		}
	}
</script>

<style>

</style>
